//form表提交
function form_sub(dom){
	var form = $(dom).parents("form");
	var url =  form.attr("action");
	$.ajax({
		url:url,
		type:"POST",
		data:form.serialize(),
		success:function(data){
			var list = new Array();
			list = eval('(' + data +')');
			console.log(list);
			if(list['errcode'] == 0){
				alert(list['message']);
				if(list['url'] == "" ||list['url'] == undefined){
					window.location.reload();
				}else{
					window.location.href = list['url'];
				} 
			}else{
				alert(list['message']);
				if(list['content'] != ""){
					$("input[name='" + list['content'] + "']").focus();
				}
				if(list['url'] != ""  && list['url'] != undefined){
					window.location.href = list['url'];
				}
			}
		}
	})
}

function form_img_sub(dom){
	var form = $(dom).parents("form");
	form.ajaxSubmit({
		success:function(data){
			console.log(data);
			var list = new Array();
			list = eval('(' + data + ')');
			if(list['errcode'] == 0){
				alert(list['message']);
				if(list['url'] == "" || list['url'] == undefined){
					window.location.reload();
				}else{
					window.location.href = list['url'];
				} 
			}else{
				alert(list['message']);
				if(list['url'] != ""  && list['url'] != undefined){
					window.location.href = list['url'];
				}
			}
		}
	});
}


//ajax url上传
function ajax_sub(url,param){
	$.ajax({
		url:url,
		type:"POST",
		data:param,
		success:function(data){
			var list = new Array();
			list = eval('(' + data +')');
			if(list['errcode'] == 0){
				alert(list['message']);
				if(list['url'] == "" || list['url'] == undefined){
					window.location.reload();
				}else{
					window.location.href = list['url'];
				} 
			}else{
				alert(list['message']);
				if(list['url'] != ""  && list['url'] != undefined){
					window.location.href = list['url'];
				}
			}
		}
	})
}



